

import 'package:erp/Events/EventAddrs.dart';
import 'package:erp/Store/AccountStore.dart';
import 'package:erp/global.dart';

void registerProductCodeEvents() {
  globalBus.subscribe(Events.PRODUCTCODE_GENERATE_REQUEST, (bus, _) async {
    try {
      var code = await externalInterface.generateNewProductCode(AccountStore.signInResult.token);
      globalBus.publish(Events.PRODUCTCODE_GENERATE_SUCCESS, code);
    }
    catch (exception){
      globalBus.publish(Events.PRODUCTCODE_GENERATE_ERROR, exception);
    }
  });
}